import Footer from './Footer'
import { applyApi, checkApi } from '../../../../common/api/applyManage'
import Bus from '@/common/bus'

export default {
    components: {
        Footer,
    },
    data() {
        return {
            applyApi,
            checkApi,
            Bus,
            isShowSave: false,
        }
    },
    mounted() {
        let roleCode = this.$store.state.userInfo?.roleCode
        if (roleCode === 2) {
            this.isShowSave = this.record?.cjzt === 2
        }
        if (roleCode > 2) {
            this.isShowSave = this.record?.cjzt === 5
        }
    },
    props: {
        record: {
            type: Object,
            required: false,
        },
        isEdit: {
            type: Boolean,
            required: false,
        },
    },
    methods: {
        back() {
            this.$emit('updateState', 'back')
        },
        nextStep() {
            this.$emit('updateState', 'nextStep')
        },
        previousStep() {
            this.$emit('updateState', 'previousStep')
        },
        save() {
            this.$refs.form.validate(async valid => {
                if (valid) {
                    console.log(valid)
                    if (this.saveApi instanceof Function) {
                        this.saveApi()
                    }
                } else {
                    return false
                }
            })
        },
    },
}
